from lark import Lark
grammar = """
    start: expr
    expr: NUMBER "+" NUMBER -> add
        | NUMBER "-" NUMBER -> sub
    %import common.NUMBER
    %ignore " "
"""
parser = Lark(grammar)
tree = parser.parse("3 + 5")
print(tree.pretty())  # 输出结构化语法树
